<?php
$errors = array();
if ($_GET) {
	// run the validation script
	require_once('library.php');
	try {
		
	$searchtext = $_GET['searchtext'];
 
$sql = mysql_query("select * from `items` where itemName like '%$searchtext%' or keywords like '%$searchtext%' or description like '%$searchtext%'");
 
while ($row = mysql_fetch_array($sql)){
    echo 'ID: '.$row['ID'];
    echo '<br/> First Name: '.$row['FName'];
    echo '<br/> Last Name: '.$row['LName'];
    echo '<br/> Phone: '.$row['Phone'];
    echo '<br/><br/>';
    }
		
		
		
		
		
		
		
		
		
		
		// check that username is 6-50 alphanumeric and not already taken in DB
		$val = new Zend_Validate();
		$lenght = new Zend_Validate_StringLength(6,50);
		$val->addValidator($lenght);
		$val->addValidator(new Zend_Validate_Alnum());
		$userNameChanged = FALSE;
		if (!$val->isValid($_POST['userName'])){
			$errors['userName'] = '*** Use 6-50 letters or numbers only -> ';
			}else{
			   $sql = 'SELECT userName FROM `users` WHERE `userId`= ? ORDER BY userName';
			   $result = $dbRead->fetchAll($sql,$_GET['userId']);
				
			  if($result[0]['userName'] === $_POST['userName']){
				$userNameChanged = FALSE;
			  } else{
				$userNameChanged = TRUE;
				$sql = $dbRead->quoteInto('SELECT userName from users WHERE userName = ?',$_POST['userName']);
				$result = $dbRead->fetchAll($sql);
				if ($result){
					$errors['userName'] = '*** '.$_POST['userName'] . ' is already in use -> ';
				}
			  }
		}
			echo $userNameChanged;
	$hasPassword = 0;
//Check if anything was entered in password fields		
	if(!empty($_POST['password']) || !empty($_POST['confirmPassword'])){
		$hasPassword = 1;
	}


	
//If there are no errors	
		if(!$errors){
		
		}
		
			
	} catch (Exception $e){
		echo $e->getMessage();
	}
}